﻿using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
// 添加必要的命名空间引用
using System.Drawing.Drawing2D;
using DevExpress.XtraTab;
using System.Collections.Generic;

// 自定义事件参数类，用于表格单元格点击事件
public class TableLayoutCellClickEventArgs : EventArgs
{
    public int Row { get; private set; }
    public int Column { get; private set; }

    public TableLayoutCellClickEventArgs(int row, int column)
    {
        Row = row;
        Column = column;
    }
}

// 扩展TableLayoutPanel，添加CellClick事件
public static class TableLayoutPanelExtensions
{
    // 事件键名
    private const string EVENT_KEY = "CellClickEvent";
    
    // 添加CellClick事件
    public static void AddCellClickEvent(this TableLayoutPanel panel, EventHandler<TableLayoutCellClickEventArgs> handler)
    {
        // 获取或创建事件字典
        if (!(panel.Tag is Dictionary<string, object> dict))
        {
            dict = new Dictionary<string, object>();
            panel.Tag = dict;
        }
        
        // 获取或创建事件列表
        if (!dict.ContainsKey(EVENT_KEY))
        {
            dict[EVENT_KEY] = new List<EventHandler<TableLayoutCellClickEventArgs>>();
        }
        
        // 添加事件处理程序
        var handlers = dict[EVENT_KEY] as List<EventHandler<TableLayoutCellClickEventArgs>>;
        handlers.Add(handler);
    }
    
    // 触发CellClick事件
    public static void OnCellClick(this TableLayoutPanel panel, TableLayoutCellClickEventArgs e)
    {
        if (panel.Tag is Dictionary<string, object> dict && dict.ContainsKey(EVENT_KEY))
        {
            var handlers = dict[EVENT_KEY] as List<EventHandler<TableLayoutCellClickEventArgs>>;
            foreach (var handler in handlers)
            {
                handler(panel, e);
            }
        }
    }
}

namespace MesProjectWinform.BasicData.基础实现.chanpin
{
    public partial class Daping : DevExpress.XtraEditors.XtraForm
    {
        // 声明控件
        private Panel panelTop;
        
        // 标签页控件
        private XtraTabControl tabControl;
        private XtraTabPage pageOverview;
        private XtraTabPage pageProduction;
        private XtraTabPage pageOrders;
        private XtraTabPage pageAnalytics;
        
        // 顶部数据卡片
        private Panel cardOutputCount;
        private Panel cardProductionCount;
        private Panel cardInventoryCount;
        private Panel cardDefectCount;
        
        // 中部图表
        private Panel panelMonthlyProduction;
        private Panel panelTopWorkers;
        
        // 底部表格和图表
        private Panel panelWorkOrders;
        private Panel panelCustomerOrders;
        private Panel panelWIP;
        
        // 交互按钮
        private Button btnRefresh;
        private Button btnExport;
        private ComboBox cmbTimeRange;
        
        // 随机数生成器用于模拟数据
        private Random random = new Random();
        
        // 存储图表数据
        private Dictionary<string, int[]> chartData;

        public Daping()
        {
            InitializeComponent();
            InitializeCustomComponents();
            LoadDummyData();
        }

        private void InitializeCustomComponents()
        {
            this.SuspendLayout();
            
            // 设置窗体属性
            this.Text = "生产监控仪表板";
            this.WindowState = FormWindowState.Maximized;
            this.BackColor = Color.FromArgb(240, 240, 240);
            
            // 初始化图表数据
            InitializeChartData();
            
            // 创建顶部面板
            panelTop = new Panel();
            panelTop.Dock = DockStyle.Top;
            panelTop.Height = 140; // 增加高度，减少拥挤感
            panelTop.Padding = new Padding(15);
            panelTop.BackColor = Color.FromArgb(250, 250, 250);
            
            // 创建标签页控件
            tabControl = new XtraTabControl();
            tabControl.Dock = DockStyle.Fill;
            tabControl.HeaderLocation = DevExpress.XtraTab.TabHeaderLocation.Top;
            tabControl.HeaderOrientation = DevExpress.XtraTab.TabOrientation.Horizontal;
            tabControl.AppearancePage.Header.Font = new Font("微软雅黑", 10F);
            tabControl.AppearancePage.Header.Options.UseFont = true;
            
            // 创建标签页
            pageOverview = new XtraTabPage();
            pageOverview.Text = "总览";
            pageOverview.BackColor = Color.FromArgb(240, 240, 240);
            
            pageProduction = new XtraTabPage();
            pageProduction.Text = "生产详情";
            pageProduction.BackColor = Color.FromArgb(240, 240, 240);
            
            pageOrders = new XtraTabPage();
            pageOrders.Text = "订单管理";
            pageOrders.BackColor = Color.FromArgb(240, 240, 240);
            
            pageAnalytics = new XtraTabPage();
            pageAnalytics.Text = "数据分析";
            pageAnalytics.BackColor = Color.FromArgb(240, 240, 240);
            
            // 添加标签页到标签控件
            tabControl.TabPages.AddRange(new XtraTabPage[] { 
                pageOverview, pageProduction, pageOrders, pageAnalytics 
            });
            
            // 创建顶部控制区域
            CreateControlPanel();
            
            // 创建顶部数据卡片
            CreateTopCards();
            
            // 创建总览页面内容
            CreateOverviewPage();
            
            // 创建生产详情页面内容
            CreateProductionPage();
            
            // 创建订单管理页面内容
            CreateOrdersPage();
            
            // 创建数据分析页面内容
            CreateAnalyticsPage();
            
            // 添加控件到窗体
            this.Controls.Add(tabControl);
            this.Controls.Add(panelTop);
            
            // 添加标签页切换事件
            tabControl.SelectedPageChanged += TabControl_SelectedPageChanged;
            
            this.ResumeLayout(false);
        }
        
        private void InitializeChartData()
        {
            // 初始化图表数据字典
            chartData = new Dictionary<string, int[]>();
            
            // 月度生产数据
            chartData["monthly"] = new int[] { 9000, 7500, 12000, 9500, 10000, 9000, 14000, 6000, 12500, 10000, 9500, 9000 };
            
            // 工序不良率数据
            chartData["defects"] = new int[] { 40, 38, 37, 36, 32, 28, 25, 22, 20, 18 };
            
            // WIP数据
            chartData["wipActual"] = new int[] { 120, 200, 150, 80, 70, 110, 130, 90, 100, 120 };
            chartData["wipPlanned"] = new int[] { 140, 230, 300, 260, 150, 120, 160, 120, 110, 130 };
        }
        
        private void CreateControlPanel()
        {
            // 创建刷新按钮
            btnRefresh = new Button();
            btnRefresh.Text = "刷新数据";
            btnRefresh.Font = new Font("微软雅黑", 9F);
            btnRefresh.Size = new Size(100, 30);
            btnRefresh.Location = new Point(15, 15);
            btnRefresh.FlatStyle = FlatStyle.Flat;
            btnRefresh.BackColor = Color.FromArgb(52, 152, 219);
            btnRefresh.ForeColor = Color.White;
            btnRefresh.Cursor = Cursors.Hand;
            btnRefresh.Click += BtnRefresh_Click;
            
            // 创建导出按钮
            btnExport = new Button();
            btnExport.Text = "导出报表";
            btnExport.Font = new Font("微软雅黑", 9F);
            btnExport.Size = new Size(100, 30);
            btnExport.Location = new Point(125, 15);
            btnExport.FlatStyle = FlatStyle.Flat;
            btnExport.BackColor = Color.FromArgb(46, 204, 113);
            btnExport.ForeColor = Color.White;
            btnExport.Cursor = Cursors.Hand;
            btnExport.Click += BtnExport_Click;
            
            // 创建时间范围选择
            cmbTimeRange = new ComboBox();
            cmbTimeRange.Font = new Font("微软雅黑", 9F);
            cmbTimeRange.Size = new Size(150, 30);
            cmbTimeRange.Location = new Point(235, 15);
            cmbTimeRange.DropDownStyle = ComboBoxStyle.DropDownList;
            cmbTimeRange.Items.AddRange(new string[] { "今日", "本周", "本月", "本季度", "今年" });
            cmbTimeRange.SelectedIndex = 2; // 默认选择"本月"
            cmbTimeRange.SelectedIndexChanged += CmbTimeRange_SelectedIndexChanged;
            
            // 创建标题标签
            Label lblTitle = new Label();
            lblTitle.Text = "生产监控仪表板";
            lblTitle.Font = new Font("微软雅黑", 16F, FontStyle.Bold);
            lblTitle.ForeColor = Color.FromArgb(60, 60, 60);
            lblTitle.AutoSize = true;
            lblTitle.Location = new Point(this.Width / 2 - 100, 15);
            
            // 创建日期时间标签
            Label lblDateTime = new Label();
            lblDateTime.Text = DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss");
            lblDateTime.Font = new Font("微软雅黑", 9F);
            lblDateTime.ForeColor = Color.Gray;
            lblDateTime.AutoSize = true;
            lblDateTime.Location = new Point(this.Width / 2 - 80, 50);
            
            // 添加控件到顶部面板
            panelTop.Controls.Add(btnRefresh);
            panelTop.Controls.Add(btnExport);
            panelTop.Controls.Add(cmbTimeRange);
            panelTop.Controls.Add(lblTitle);
            panelTop.Controls.Add(lblDateTime);
            
            // 创建定时器更新时间
            Timer timer = new Timer();
            timer.Interval = 1000; // 1秒
            timer.Tick += (sender, e) => {
                lblDateTime.Text = DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss");
            };
            timer.Start();
        }
        
        private void CreateTopCards()
        {
            // 创建一个容器面板来放置卡片
            Panel cardsContainer = new Panel();
            cardsContainer.Dock = DockStyle.Bottom;
            cardsContainer.Height = 90; // 增加高度，使卡片更宽松
            cardsContainer.Padding = new Padding(5, 0, 5, 0);
            cardsContainer.BackColor = Color.Transparent;
            
            // 创建四个数据卡片
            cardOutputCount = CreateDataCard("出货产品数", "8,323", "同比: ↑ 36%", "环比: ↓ 9%", Color.FromArgb(46, 204, 113));
            cardProductionCount = CreateDataCard("生产工单数", "7,239", "同比: ↑ 50%", "环比: ↓ 3%", Color.FromArgb(52, 152, 219));
            cardInventoryCount = CreateDataCard("在制品", "9,131", "同比: ↑ 70%", "环比: ↓ 9%", Color.FromArgb(155, 89, 182));
            cardDefectCount = CreateDataCard("不良品数", "59", "同比: ↓ 24%", "环比: ↓ 8%", Color.FromArgb(231, 76, 60));
            
            // 设置卡片位置和大小
            int cardWidth = (this.Width - 50) / 4;
            
            cardOutputCount.Width = cardWidth;
            cardOutputCount.Left = 10;
            cardOutputCount.Tag = "output";
            cardOutputCount.Click += Card_Click;
            cardOutputCount.MouseEnter += Card_MouseEnter;
            cardOutputCount.MouseLeave += Card_MouseLeave;
            cardOutputCount.Cursor = Cursors.Hand;
            
            cardProductionCount.Width = cardWidth;
            cardProductionCount.Left = cardOutputCount.Right + 10;
            cardProductionCount.Tag = "production";
            cardProductionCount.Click += Card_Click;
            cardProductionCount.MouseEnter += Card_MouseEnter;
            cardProductionCount.MouseLeave += Card_MouseLeave;
            cardProductionCount.Cursor = Cursors.Hand;
            
            cardInventoryCount.Width = cardWidth;
            cardInventoryCount.Left = cardProductionCount.Right + 10;
            cardInventoryCount.Tag = "inventory";
            cardInventoryCount.Click += Card_Click;
            cardInventoryCount.MouseEnter += Card_MouseEnter;
            cardInventoryCount.MouseLeave += Card_MouseLeave;
            cardInventoryCount.Cursor = Cursors.Hand;
            
            cardDefectCount.Width = cardWidth;
            cardDefectCount.Left = cardInventoryCount.Right + 10;
            cardDefectCount.Tag = "defect";
            cardDefectCount.Click += Card_Click;
            cardDefectCount.MouseEnter += Card_MouseEnter;
            cardDefectCount.MouseLeave += Card_MouseLeave;
            cardDefectCount.Cursor = Cursors.Hand;
            
            // 添加卡片到容器面板
            cardsContainer.Controls.Add(cardOutputCount);
            cardsContainer.Controls.Add(cardProductionCount);
            cardsContainer.Controls.Add(cardInventoryCount);
            cardsContainer.Controls.Add(cardDefectCount);
            
            // 添加容器面板到顶部面板
            panelTop.Controls.Add(cardsContainer);
        }
        
        // 卡片点击事件
        private void Card_Click(object sender, EventArgs e)
        {
            Panel card = sender as Panel;
            string cardType = card.Tag.ToString();
            
            // 根据卡片类型切换到相应的标签页并显示详细信息
            switch (cardType)
            {
                case "output":
                    tabControl.SelectedTabPage = pageOrders;
                    MessageBox.Show("查看出货产品详细数据", "详情", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                case "production":
                    tabControl.SelectedTabPage = pageProduction;
                    MessageBox.Show("查看生产工单详细数据", "详情", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                case "inventory":
                    tabControl.SelectedTabPage = pageProduction;
                    MessageBox.Show("查看在制品详细数据", "详情", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                case "defect":
                    tabControl.SelectedTabPage = pageAnalytics;
                    MessageBox.Show("查看不良品详细数据", "详情", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
            }
        }
        
        // 卡片鼠标进入事件 - 添加悬停效果
        private void Card_MouseEnter(object sender, EventArgs e)
        {
            Panel card = sender as Panel;
            card.BorderStyle = BorderStyle.FixedSingle;
            
            // 提升卡片，创建阴影效果
            card.Top -= 3;
            card.Invalidate(); // 强制重绘
        }
        
        // 卡片鼠标离开事件 - 恢复原样
        private void Card_MouseLeave(object sender, EventArgs e)
        {
            Panel card = sender as Panel;
            card.BorderStyle = BorderStyle.None;
            
            // 恢复位置
            card.Top += 3;
            card.Invalidate(); // 强制重绘
        }
        
        // 创建总览页面内容
        private void CreateOverviewPage()
        {
            // 创建面板容器
            Panel container = new Panel();
            container.Dock = DockStyle.Fill;
            container.Padding = new Padding(20); // 增加内边距，减少拥挤感
            
            // 创建上部面板 - 放置图表
            Panel upperPanel = new Panel();
            upperPanel.Dock = DockStyle.Top;
            upperPanel.Height = 320; // 增加高度，让图表更宽松
            upperPanel.Padding = new Padding(10); // 增加内边距
            
            // 创建月度生产图表面板
            panelMonthlyProduction = CreatePanel("工单数量", DockStyle.Left, this.Width / 2 - 30);
            
            // 创建柱状图 - 使用自定义绘制
            Panel chartMonthly = new Panel();
            chartMonthly.Dock = DockStyle.Fill;
            chartMonthly.Padding = new Padding(10, 40, 10, 10);
            chartMonthly.Tag = "monthly";
            chartMonthly.Click += Chart_Click;
            chartMonthly.Cursor = Cursors.Hand;
            
            // 添加柱状图绘制
            chartMonthly.Paint += (sender, e) => 
            {
                DrawMonthlyBarChart(e.Graphics, chartMonthly.ClientRectangle);
            };
            
            panelMonthlyProduction.Controls.Add(chartMonthly);
            
            // 创建工序不良率排名图表面板
            panelTopWorkers = CreatePanel("工序不良率排名", DockStyle.Right, this.Width / 2 - 30);
            
            // 创建水平条形图 - 使用自定义绘制
            Panel chartWorkers = new Panel();
            chartWorkers.Dock = DockStyle.Fill;
            chartWorkers.Padding = new Padding(10, 40, 10, 10);
            chartWorkers.Tag = "defects";
            chartWorkers.Click += Chart_Click;
            chartWorkers.Cursor = Cursors.Hand;
            
            // 添加条形图绘制
            chartWorkers.Paint += (sender, e) => 
            {
                DrawWorkersBarChart(e.Graphics, chartWorkers.ClientRectangle);
            };
            
            panelTopWorkers.Controls.Add(chartWorkers);
            
            // 添加到上部面板
            upperPanel.Controls.Add(panelMonthlyProduction);
            upperPanel.Controls.Add(panelTopWorkers);
            
            // 创建下部面板 - 放置表格和图表
            Panel lowerPanel = new Panel();
            lowerPanel.Dock = DockStyle.Fill;
            lowerPanel.Padding = new Padding(10, 20, 10, 10); // 增加顶部间距，减少拥挤感
            
            // 创建工单表格面板
            panelWorkOrders = CreatePanel("工单完成情况", DockStyle.Left, this.Width / 3 - 30); // 减小宽度，增加间隔
            panelWorkOrders.Height = 260; // 增加高度，减少拥挤感
            
            // 添加工单数据表格
            TableLayoutPanel tableWorkOrders = CreateTablePanel(
                new string[] { "序号", "工单号", "状态", "进度", "总数量" },
                GetWorkOrdersData()
            );
            tableWorkOrders.Location = new Point(10, 45); // 增加与标题的间距
            tableWorkOrders.Size = new Size(panelWorkOrders.Width - 25, 200); // 减小宽度，增加边距
            AddCellClickEvent(tableWorkOrders, TableWorkOrders_CellClick);
            panelWorkOrders.Controls.Add(tableWorkOrders);
            
            // 创建客户订单表格面板
            panelCustomerOrders = CreatePanel("出货订单数据", DockStyle.Left, this.Width / 3 - 30); // 减小宽度，增加间隔
            panelCustomerOrders.Height = 260; // 增加高度，减少拥挤感
            panelCustomerOrders.Left = panelWorkOrders.Right + 15; // 增加面板间距
            
            // 添加客户订单数据表格
            TableLayoutPanel tableCustomerOrders = CreateTablePanel(
                new string[] { "序号", "客户", "同比", "订单量" },
                GetCustomerOrdersData()
            );
            tableCustomerOrders.Location = new Point(10, 45); // 增加与标题的间距
            tableCustomerOrders.Size = new Size(panelCustomerOrders.Width - 25, 200); // 减小宽度，增加边距
            AddCellClickEvent(tableCustomerOrders, TableCustomerOrders_CellClick);
            panelCustomerOrders.Controls.Add(tableCustomerOrders);
            
            // 创建WIP图表面板
            panelWIP = CreatePanel("生产WIP", DockStyle.Left, this.Width / 3 - 30); // 减小宽度，增加间隔
            panelWIP.Height = 260; // 增加高度，减少拥挤感
            panelWIP.Left = panelCustomerOrders.Right + 15; // 增加面板间距
            
            // 添加WIP图表绘制区域
            Panel chartWIP = new Panel();
            chartWIP.Dock = DockStyle.Fill;
            chartWIP.Padding = new Padding(10, 40, 10, 10);
            chartWIP.Tag = "wip";
            chartWIP.Click += Chart_Click;
            chartWIP.Cursor = Cursors.Hand;
            
            // 添加WIP图表绘制
            chartWIP.Paint += (sender, e) => 
            {
                DrawWIPChart(e.Graphics, chartWIP.ClientRectangle);
            };
            
            // 添加WIP信息标签
            Panel wipInfoPanel = new Panel();
            wipInfoPanel.Dock = DockStyle.Right;
            wipInfoPanel.Width = 120;
            wipInfoPanel.BackColor = Color.Transparent;
            
            // 当日WIP数量
            Label lblWIPTitle = new Label();
            lblWIPTitle.Text = "当日WIP总数";
            lblWIPTitle.Font = new Font("微软雅黑", 9);
            lblWIPTitle.ForeColor = Color.Gray;
            lblWIPTitle.AutoSize = true;
            lblWIPTitle.Location = new Point(5, 50);
            
            Label lblWIPValue = new Label();
            lblWIPValue.Text = "341";
            lblWIPValue.Font = new Font("微软雅黑", 16, FontStyle.Bold);
            lblWIPValue.ForeColor = Color.FromArgb(52, 152, 219);
            lblWIPValue.AutoSize = true;
            lblWIPValue.Location = new Point(5, 70);
            
            Label lblWIPCompare = new Label();
            lblWIPCompare.Text = "同比上月增长 31%";
            lblWIPCompare.Font = new Font("微软雅黑", 8);
            lblWIPCompare.ForeColor = Color.FromArgb(46, 204, 113);
            lblWIPCompare.AutoSize = true;
            lblWIPCompare.Location = new Point(5, 95);
            
            // 完成总数
            Label lblCompletedTitle = new Label();
            lblCompletedTitle.Text = "完成总数";
            lblCompletedTitle.Font = new Font("微软雅黑", 9);
            lblCompletedTitle.ForeColor = Color.Gray;
            lblCompletedTitle.AutoSize = true;
            lblCompletedTitle.Location = new Point(5, 130);
            
            Label lblCompletedValue = new Label();
            lblCompletedValue.Text = "5942";
            lblCompletedValue.Font = new Font("微软雅黑", 16, FontStyle.Bold);
            lblCompletedValue.ForeColor = Color.FromArgb(52, 152, 219);
            lblCompletedValue.AutoSize = true;
            lblCompletedValue.Location = new Point(5, 150);
            
            Label lblCompletedCompare = new Label();
            lblCompletedCompare.Text = "同比上月增长 63%";
            lblCompletedCompare.Font = new Font("微软雅黑", 8);
            lblCompletedCompare.ForeColor = Color.FromArgb(46, 204, 113);
            lblCompletedCompare.AutoSize = true;
            lblCompletedCompare.Location = new Point(5, 175);
            
            // 添加到信息面板
            wipInfoPanel.Controls.Add(lblWIPTitle);
            wipInfoPanel.Controls.Add(lblWIPValue);
            wipInfoPanel.Controls.Add(lblWIPCompare);
            wipInfoPanel.Controls.Add(lblCompletedTitle);
            wipInfoPanel.Controls.Add(lblCompletedValue);
            wipInfoPanel.Controls.Add(lblCompletedCompare);
            
            // 添加到WIP面板
            panelWIP.Controls.Add(wipInfoPanel);
            panelWIP.Controls.Add(chartWIP);
            
            // 添加到下部面板
            lowerPanel.Controls.Add(panelWorkOrders);
            lowerPanel.Controls.Add(panelCustomerOrders);
            lowerPanel.Controls.Add(panelWIP);
            
            // 添加面板到容器
            container.Controls.Add(lowerPanel);
            container.Controls.Add(upperPanel);
            
            // 添加容器到总览页面
            pageOverview.Controls.Add(container);
        }
        
        // 创建生产详情页面内容
        private void CreateProductionPage()
        {
            // 创建面板容器
            Panel container = new Panel();
            container.Dock = DockStyle.Fill;
            container.Padding = new Padding(25); // 增加内边距，减少拥挤感
            
            // 创建标题标签
            Label lblTitle = new Label();
            lblTitle.Text = "生产详情";
            lblTitle.Font = new Font("微软雅黑", 14, FontStyle.Bold);
            lblTitle.ForeColor = Color.FromArgb(60, 60, 60);
            lblTitle.AutoSize = true;
            lblTitle.Location = new Point(15, 15);
            
            // 创建筛选控件
            Label lblFilter = new Label();
            lblFilter.Text = "筛选条件:";
            lblFilter.Font = new Font("微软雅黑", 10);
            lblFilter.ForeColor = Color.FromArgb(80, 80, 80);
            lblFilter.AutoSize = true;
            lblFilter.Location = new Point(15, 50);
            
            ComboBox cmbProductionFilter = new ComboBox();
            cmbProductionFilter.Items.AddRange(new string[] { "全部", "已完成", "进行中", "未开始" });
            cmbProductionFilter.SelectedIndex = 0;
            cmbProductionFilter.Location = new Point(100, 48);
            cmbProductionFilter.Size = new Size(150, 25);
            cmbProductionFilter.DropDownStyle = ComboBoxStyle.DropDownList;
            cmbProductionFilter.SelectedIndexChanged += (sender, e) => {
                MessageBox.Show("筛选条件已更改为: " + cmbProductionFilter.SelectedItem.ToString(), 
                    "筛选", MessageBoxButtons.OK, MessageBoxIcon.Information);
            };
            
            // 创建生产数据表格
            TableLayoutPanel tableProduction = CreateTablePanel(
                new string[] { "序号", "工单号", "产品名称", "计划数量", "已完成", "不良品", "开始时间", "状态", "操作" },
                new string[][] {
                    new string[] { "1", "MO202112160001", "电路板A型", "500", "274", "12", "2023-10-01", "已完工", "查看" },
                    new string[] { "2", "MO202112160002", "电路板B型", "300", "141", "8", "2023-10-05", "已完工", "查看" },
                    new string[] { "3", "MO202112160003", "电路板C型", "400", "251", "15", "2023-10-08", "已完工", "查看" },
                    new string[] { "4", "MO202112160004", "电路板D型", "600", "491", "23", "2023-10-10", "已完工", "查看" },
                    new string[] { "5", "MO202112160005", "电路板E型", "800", "678", "31", "2023-10-15", "已完工", "查看" },
                    new string[] { "6", "MO202112160006", "电路板F型", "450", "320", "18", "2023-10-18", "进行中", "查看" },
                    new string[] { "7", "MO202112160007", "电路板G型", "550", "0", "0", "2023-10-25", "未开始", "查看" },
                    new string[] { "8", "MO202112160008", "电路板H型", "700", "0", "0", "2023-10-30", "未开始", "查看" }
                }
            );
            tableProduction.Location = new Point(15, 90);
            tableProduction.Size = new Size(this.Width - 60, 400);
            AddCellClickEvent(tableProduction, TableProduction_CellClick);
            
            // 添加控件到容器
            container.Controls.Add(lblTitle);
            container.Controls.Add(lblFilter);
            container.Controls.Add(cmbProductionFilter);
            container.Controls.Add(tableProduction);
            
            // 添加容器到生产详情页面
            pageProduction.Controls.Add(container);
        }
        
        // 创建订单管理页面内容
        private void CreateOrdersPage()
        {
            // 创建面板容器
            Panel container = new Panel();
            container.Dock = DockStyle.Fill;
            container.Padding = new Padding(25); // 增加内边距，减少拥挤感
            
            // 创建标题标签
            Label lblTitle = new Label();
            lblTitle.Text = "订单管理";
            lblTitle.Font = new Font("微软雅黑", 14, FontStyle.Bold);
            lblTitle.ForeColor = Color.FromArgb(60, 60, 60);
            lblTitle.AutoSize = true;
            lblTitle.Location = new Point(15, 15);
            
            // 创建筛选控件
            Label lblFilter = new Label();
            lblFilter.Text = "客户筛选:";
            lblFilter.Font = new Font("微软雅黑", 10);
            lblFilter.ForeColor = Color.FromArgb(80, 80, 80);
            lblFilter.AutoSize = true;
            lblFilter.Location = new Point(15, 50);
            
            ComboBox cmbCustomerFilter = new ComboBox();
            cmbCustomerFilter.Items.AddRange(new string[] { 
                "全部客户", 
                "广东电器电子有限公司", 
                "华瑞科技有限公司", 
                "华为技术有限公司", 
                "小米科技有限责任公司", 
                "智联集团", 
                "广东移动通信有限公司" 
            });
            cmbCustomerFilter.SelectedIndex = 0;
            cmbCustomerFilter.Location = new Point(100, 48);
            cmbCustomerFilter.Size = new Size(200, 25);
            cmbCustomerFilter.DropDownStyle = ComboBoxStyle.DropDownList;
            cmbCustomerFilter.SelectedIndexChanged += (sender, e) => {
                MessageBox.Show("客户筛选已更改为: " + cmbCustomerFilter.SelectedItem.ToString(), 
                    "筛选", MessageBoxButtons.OK, MessageBoxIcon.Information);
            };
            
            // 创建按钮
            Button btnAddOrder = new Button();
            btnAddOrder.Text = "新增订单";
            btnAddOrder.Font = new Font("微软雅黑", 9F);
            btnAddOrder.Size = new Size(100, 30);
            btnAddOrder.Location = new Point(this.Width - 150, 48);
            btnAddOrder.FlatStyle = FlatStyle.Flat;
            btnAddOrder.BackColor = Color.FromArgb(46, 204, 113);
            btnAddOrder.ForeColor = Color.White;
            btnAddOrder.Cursor = Cursors.Hand;
            btnAddOrder.Click += (sender, e) => {
                MessageBox.Show("新增订单功能将在此处实现", "功能提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            };
            
            // 创建订单数据表格
            TableLayoutPanel tableOrders = CreateTablePanel(
                new string[] { "订单号", "客户", "产品", "数量", "交付日期", "状态", "操作" },
                new string[][] {
                    new string[] { "SO20231001", "广东电器电子有限公司", "电路板A型", "1099", "2023-11-15", "已发货", "查看" },
                    new string[] { "SO20231002", "华瑞科技有限公司", "电路板B型", "7093", "2023-11-20", "生产中", "查看" },
                    new string[] { "SO20231003", "华为技术有限公司", "电路板C型", "5689", "2023-11-25", "待生产", "查看" },
                    new string[] { "SO20231004", "小米科技有限责任公司", "电路板D型", "2375", "2023-11-30", "已发货", "查看" },
                    new string[] { "SO20231005", "智联集团", "电路板E型", "3504", "2023-12-05", "生产中", "查看" },
                    new string[] { "SO20231006", "广东移动通信有限公司", "电路板F型", "2261", "2023-12-10", "待生产", "查看" }
                }
            );
            tableOrders.Location = new Point(15, 90);
            tableOrders.Size = new Size(this.Width - 60, 400);
            AddCellClickEvent(tableOrders, TableOrders_CellClick);
            
            // 添加控件到容器
            container.Controls.Add(lblTitle);
            container.Controls.Add(lblFilter);
            container.Controls.Add(cmbCustomerFilter);
            container.Controls.Add(btnAddOrder);
            container.Controls.Add(tableOrders);
            
            // 添加容器到订单管理页面
            pageOrders.Controls.Add(container);
        }
        
        // 创建数据分析页面内容
        private void CreateAnalyticsPage()
        {
            // 创建面板容器
            Panel container = new Panel();
            container.Dock = DockStyle.Fill;
            container.Padding = new Padding(25); // 增加内边距，减少拥挤感
            
            // 创建标题标签
            Label lblTitle = new Label();
            lblTitle.Text = "数据分析";
            lblTitle.Font = new Font("微软雅黑", 14, FontStyle.Bold);
            lblTitle.ForeColor = Color.FromArgb(60, 60, 60);
            lblTitle.AutoSize = true;
            lblTitle.Location = new Point(15, 15);
            
            // 创建分析选项
            Label lblAnalysisType = new Label();
            lblAnalysisType.Text = "分析类型:";
            lblAnalysisType.Font = new Font("微软雅黑", 10);
            lblAnalysisType.ForeColor = Color.FromArgb(80, 80, 80);
            lblAnalysisType.AutoSize = true;
            lblAnalysisType.Location = new Point(15, 50);
            
            ComboBox cmbAnalysisType = new ComboBox();
            cmbAnalysisType.Items.AddRange(new string[] { 
                "不良品分析", 
                "产能分析", 
                "订单交付分析", 
                "客户满意度分析" 
            });
            cmbAnalysisType.SelectedIndex = 0;
            cmbAnalysisType.Location = new Point(100, 48);
            cmbAnalysisType.Size = new Size(200, 25);
            cmbAnalysisType.DropDownStyle = ComboBoxStyle.DropDownList;
            cmbAnalysisType.SelectedIndexChanged += (sender, e) => {
                MessageBox.Show("分析类型已更改为: " + cmbAnalysisType.SelectedItem.ToString(), 
                    "分析", MessageBoxButtons.OK, MessageBoxIcon.Information);
            };
            
            // 创建按钮
            Button btnGenerateReport = new Button();
            btnGenerateReport.Text = "生成报表";
            btnGenerateReport.Font = new Font("微软雅黑", 9F);
            btnGenerateReport.Size = new Size(100, 30);
            btnGenerateReport.Location = new Point(this.Width - 150, 48);
            btnGenerateReport.FlatStyle = FlatStyle.Flat;
            btnGenerateReport.BackColor = Color.FromArgb(52, 152, 219);
            btnGenerateReport.ForeColor = Color.White;
            btnGenerateReport.Cursor = Cursors.Hand;
            btnGenerateReport.Click += (sender, e) => {
                MessageBox.Show("报表生成功能将在此处实现", "功能提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            };
            
            // 创建分析图表面板
            Panel analysisPanel = new Panel();
            analysisPanel.Location = new Point(15, 90);
            analysisPanel.Size = new Size(this.Width - 60, 400);
            analysisPanel.BackColor = Color.White;
            analysisPanel.BorderStyle = BorderStyle.None;
            
            // 添加圆角和阴影效果
            analysisPanel.Paint += (sender, e) =>
            {
                Rectangle rect = new Rectangle(0, 0, analysisPanel.Width - 1, analysisPanel.Height - 1);
                using (GraphicsPath path = RoundedRect(rect, 8))
                {
                    e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                    
                    // 绘制阴影效果
                    using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(20, 0, 0, 0)))
                    {
                        e.Graphics.FillRectangle(shadowBrush, new Rectangle(4, 4, rect.Width, rect.Height));
                    }
                    
                    // 填充背景
                    using (SolidBrush fillBrush = new SolidBrush(Color.White))
                    {
                        e.Graphics.FillPath(fillBrush, path);
                    }
                }
            };
            
            // 添加控件到容器
            container.Controls.Add(lblTitle);
            container.Controls.Add(lblAnalysisType);
            container.Controls.Add(cmbAnalysisType);
            container.Controls.Add(btnGenerateReport);
            container.Controls.Add(analysisPanel);
            
            // 添加容器到数据分析页面
            pageAnalytics.Controls.Add(container);
        }
        
        // 表格单元格点击事件
        private void TableWorkOrders_CellClick(object sender, TableLayoutCellClickEventArgs e)
        {
            if (e.Row > 0) // 排除标题行
            {
                string workOrderId = (sender as TableLayoutPanel).GetControlFromPosition(1, e.Row).Text;
                MessageBox.Show("查看工单详情: " + workOrderId, "工单详情", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        
        private void TableCustomerOrders_CellClick(object sender, TableLayoutCellClickEventArgs e)
        {
            if (e.Row > 0) // 排除标题行
            {
                string customer = (sender as TableLayoutPanel).GetControlFromPosition(1, e.Row).Text;
                MessageBox.Show("查看客户订单详情: " + customer, "客户订单", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        
        private void TableProduction_CellClick(object sender, TableLayoutCellClickEventArgs e)
        {
            if (e.Row > 0 && e.Column == 8) // "操作"列
            {
                string workOrderId = (sender as TableLayoutPanel).GetControlFromPosition(1, e.Row).Text;
                MessageBox.Show("查看生产工单详情: " + workOrderId, "生产详情", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        
        private void TableOrders_CellClick(object sender, TableLayoutCellClickEventArgs e)
        {
            if (e.Row > 0 && e.Column == 6) // "操作"列
            {
                string orderId = (sender as TableLayoutPanel).GetControlFromPosition(0, e.Row).Text;
                MessageBox.Show("查看订单详情: " + orderId, "订单详情", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        
        // 图表点击事件
        private void Chart_Click(object sender, EventArgs e)
        {
            Panel chart = sender as Panel;
            string chartType = chart.Tag.ToString();
            
            switch (chartType)
            {
                case "monthly":
                    MessageBox.Show("查看月度生产数据详情", "图表详情", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                case "defects":
                    MessageBox.Show("查看工序不良率详情", "图表详情", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                case "wip":
                    MessageBox.Show("查看WIP详情", "图表详情", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
            }
        }
        
        // 标签页切换事件
        private void TabControl_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
        {
            // 可以在这里根据选中的标签页执行相应的操作
            string pageName = e.Page.Text;
            Console.WriteLine("切换到页面: " + pageName);
        }
        
        // 刷新按钮点击事件
        private void BtnRefresh_Click(object sender, EventArgs e)
        {
            // 模拟数据刷新
            Random random = new Random();
            
            // 随机更新卡片数据
            foreach (Control control in panelTop.Controls)
            {
                if (control is Panel cardsContainer)
                {
                    foreach (Control card in cardsContainer.Controls)
                    {
                        if (card is Panel dataCard)
                        {
                            // 查找值标签并更新
                            foreach (Control c in dataCard.Controls)
                            {
                                if (c is Label lbl && lbl.Font.Size > 15) // 找到大字体的值标签
                                {
                                    int baseValue = int.Parse(lbl.Text.Replace(",", ""));
                                    int newValue = baseValue + random.Next(-500, 500);
                                    lbl.Text = newValue.ToString("N0");
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            
            // 更新图表数据
            for (int i = 0; i < chartData["monthly"].Length; i++)
            {
                chartData["monthly"][i] = chartData["monthly"][i] + random.Next(-1000, 1000);
            }
            
            // 强制重绘所有图表
            this.Invalidate(true);
            
            MessageBox.Show("数据已刷新", "刷新", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        
        // 导出按钮点击事件
        private void BtnExport_Click(object sender, EventArgs e)
        {
            MessageBox.Show("报表导出功能将在此处实现", "导出", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        
        // 时间范围选择事件
        private void CmbTimeRange_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selectedRange = cmbTimeRange.SelectedItem.ToString();
            MessageBox.Show("已选择时间范围: " + selectedRange, "时间范围", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        
        private Panel CreateDataCard(string title, string value, string upTrend, string downTrend, Color iconColor)
        {
            Panel card = new Panel();
            card.Height = 80;
            card.BackColor = Color.White;
            card.BorderStyle = BorderStyle.None;
            
            // 圆角效果和阴影 - 使用分层绘制
            card.Paint += (sender, e) =>
            {
                Rectangle rect = new Rectangle(0, 0, card.Width - 1, card.Height - 1);
                using (GraphicsPath path = RoundedRect(rect, 8))
                {
                    e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                    
                    // 绘制阴影效果
                    using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(20, 0, 0, 0)))
                    {
                        e.Graphics.FillRectangle(shadowBrush, new Rectangle(4, 4, rect.Width, rect.Height));
                    }
                    
                    // 填充背景
                    using (SolidBrush fillBrush = new SolidBrush(Color.White))
                    {
                        e.Graphics.FillPath(fillBrush, path);
                    }
                    
                    // 绘制左侧彩色条纹
                    using (SolidBrush stripeBrush = new SolidBrush(iconColor))
                    {
                        e.Graphics.FillRectangle(stripeBrush, new Rectangle(0, 0, 5, card.Height));
                    }
                }
            };
            
            // 标题标签
            Label lblTitle = new Label();
            lblTitle.Text = title;
            lblTitle.Font = new Font("微软雅黑", 10);
            lblTitle.ForeColor = Color.Gray;
            lblTitle.AutoSize = true;
            lblTitle.Location = new Point(15, 10);
            lblTitle.BackColor = Color.Transparent;
            
            // 数值标签
            Label lblValue = new Label();
            lblValue.Text = value;
            lblValue.Font = new Font("微软雅黑", 18, FontStyle.Bold);
            lblValue.AutoSize = true;
            lblValue.Location = new Point(15, 30);
            lblValue.BackColor = Color.Transparent;
            
            // 趋势标签
            Label lblTrend1 = new Label();
            lblTrend1.Text = upTrend;
            lblTrend1.Font = new Font("微软雅黑", 9);
            lblTrend1.ForeColor = upTrend.Contains("↑") ? Color.Green : Color.Red;
            lblTrend1.AutoSize = true;
            lblTrend1.Location = new Point(15, 60);
            lblTrend1.BackColor = Color.Transparent;
            
            Label lblTrend2 = new Label();
            lblTrend2.Text = downTrend;
            lblTrend2.Font = new Font("微软雅黑", 9);
            lblTrend2.ForeColor = downTrend.Contains("↑") ? Color.Green : Color.Red;
            lblTrend2.AutoSize = true;
            lblTrend2.Location = new Point(lblTrend1.Right + 20, 60);
            lblTrend2.BackColor = Color.Transparent;
            
            // 图标指示器
            Panel iconIndicator = new Panel();
            iconIndicator.Width = 30;
            iconIndicator.Height = 30;
            iconIndicator.BackColor = Color.Transparent;
            iconIndicator.Location = new Point(card.Width - 45, 25);
            
            // 为图标指示器添加绘图事件
            iconIndicator.Paint += (sender, e) =>
            {
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                
                // 绘制圆形图标背景
                using (SolidBrush iconBrush = new SolidBrush(iconColor))
                {
                    e.Graphics.FillEllipse(iconBrush, new Rectangle(0, 0, 30, 30));
                }
                
                // 绘制图标内容 - 简单的线条指示器
                using (Pen iconPen = new Pen(Color.White, 2))
                {
                    if (title.Contains("出货"))
                    {
                        // 向上箭头
                        e.Graphics.DrawLine(iconPen, 10, 20, 15, 10);
                        e.Graphics.DrawLine(iconPen, 15, 10, 20, 20);
                        e.Graphics.DrawLine(iconPen, 15, 10, 15, 25);
                    }
                    else if (title.Contains("生产"))
                    {
                        // 文档图标
                        e.Graphics.DrawRectangle(iconPen, 8, 8, 14, 16);
                        e.Graphics.DrawLine(iconPen, 11, 13, 19, 13);
                        e.Graphics.DrawLine(iconPen, 11, 18, 19, 18);
                    }
                    else if (title.Contains("在制品"))
                    {
                        // 旋转图标
                        e.Graphics.DrawEllipse(iconPen, 8, 8, 14, 14);
                        e.Graphics.DrawLine(iconPen, 15, 15, 22, 22);
                    }
                    else if (title.Contains("不良品"))
                    {
                        // X图标
                        e.Graphics.DrawLine(iconPen, 10, 10, 20, 20);
                        e.Graphics.DrawLine(iconPen, 20, 10, 10, 20);
                    }
                }
            };
            
            // 添加控件到卡片
            card.Controls.Add(lblTitle);
            card.Controls.Add(lblValue);
            card.Controls.Add(lblTrend1);
            card.Controls.Add(lblTrend2);
            card.Controls.Add(iconIndicator);
            
            // 调整大小时重新布局
            card.Resize += (sender, e) => {
                iconIndicator.Location = new Point(card.Width - 45, 25);
            };
            
            return card;
        }
        
        // 辅助方法：创建圆角矩形路径
        private GraphicsPath RoundedRect(Rectangle rect, int radius)
        {
            GraphicsPath path = new GraphicsPath();
            int diameter = radius * 2;
            
            // 左上角弧
            path.AddArc(rect.X, rect.Y, diameter, diameter, 180, 90);
            // 顶边
            path.AddLine(rect.X + radius, rect.Y, rect.Right - radius, rect.Y);
            // 右上角弧
            path.AddArc(rect.Right - diameter, rect.Y, diameter, diameter, 270, 90);
            // 右边
            path.AddLine(rect.Right, rect.Y + radius, rect.Right, rect.Bottom - radius);
            // 右下角弧
            path.AddArc(rect.Right - diameter, rect.Bottom - diameter, diameter, diameter, 0, 90);
            // 底边
            path.AddLine(rect.Right - radius, rect.Bottom, rect.X + radius, rect.Bottom);
            // 左下角弧
            path.AddArc(rect.X, rect.Bottom - diameter, diameter, diameter, 90, 90);
            // 左边
            path.AddLine(rect.X, rect.Bottom - radius, rect.X, rect.Y + radius);
            
            path.CloseFigure();
            return path;
        }
        
        private void CreateMiddleCharts()
        {
            // 创建月度生产图表面板
            panelMonthlyProduction = CreatePanel("工单数量", DockStyle.Left, this.Width / 2 - 20);
            
            // 创建柱状图 - 使用自定义绘制
            Panel chartMonthly = new Panel();
            chartMonthly.Dock = DockStyle.Fill;
            chartMonthly.Padding = new Padding(10, 40, 10, 10);
            
            // 添加柱状图绘制
            chartMonthly.Paint += (sender, e) => 
            {
                DrawMonthlyBarChart(e.Graphics, chartMonthly.ClientRectangle);
            };
            
            panelMonthlyProduction.Controls.Add(chartMonthly);
            
            // 创建工人排行图表面板
            panelTopWorkers = CreatePanel("工序不良率排名", DockStyle.Right, this.Width / 2 - 20);
            
            // 创建水平条形图 - 使用自定义绘制
            Panel chartWorkers = new Panel();
            chartWorkers.Dock = DockStyle.Fill;
            chartWorkers.Padding = new Padding(10, 40, 10, 10);
            
            // 添加条形图绘制
            chartWorkers.Paint += (sender, e) => 
            {
                DrawWorkersBarChart(e.Graphics, chartWorkers.ClientRectangle);
            };
            
            panelTopWorkers.Controls.Add(chartWorkers);
            
            // 这里不需要添加到中部面板，因为已经在CreateOverviewPage方法中处理了
        }
        
        // 创建面板的辅助方法
        private Panel CreatePanel(string title, DockStyle dockStyle, int width)
        {
            Panel panel = new Panel();
            panel.Dock = dockStyle;
            panel.Width = width;
            panel.BackColor = Color.White;
            panel.BorderStyle = BorderStyle.None;
            
            // 添加圆角和阴影效果
            panel.Paint += (sender, e) =>
            {
                Rectangle rect = new Rectangle(0, 0, panel.Width - 1, panel.Height - 1);
                using (GraphicsPath path = RoundedRect(rect, 8))
                {
                    e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                    
                    // 绘制阴影效果
                    using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(20, 0, 0, 0)))
                    {
                        e.Graphics.FillRectangle(shadowBrush, new Rectangle(4, 4, rect.Width, rect.Height));
                    }
                    
                    // 填充背景
                    using (SolidBrush fillBrush = new SolidBrush(Color.White))
                    {
                        e.Graphics.FillPath(fillBrush, path);
                    }
                }
            };
            
            // 添加标题
            Label lblTitle = new Label();
            lblTitle.Text = title;
            lblTitle.Font = new Font("微软雅黑", 12, FontStyle.Bold);
            lblTitle.ForeColor = Color.FromArgb(60, 60, 60);
            lblTitle.AutoSize = true;
            lblTitle.Location = new Point(15, 12);
            lblTitle.BackColor = Color.Transparent;
            
            panel.Controls.Add(lblTitle);
            
            return panel;
        }
        
        // 绘制月度柱状图
        private void DrawMonthlyBarChart(Graphics g, Rectangle bounds)
        {
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            
            // 柱状图数据 - 12个月
            int[] monthlyData = { 9000, 7500, 12000, 9500, 10000, 9000, 14000, 6000, 12500, 10000, 9500, 9000 };
            string[] months = { "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" };
            
            int maxValue = monthlyData.Max();
            int padding = 40;
            int leftPadding = 40;
            int bottomPadding = 30;
            int availableWidth = bounds.Width - leftPadding - padding;
            int availableHeight = bounds.Height - padding - bottomPadding;
            int barCount = monthlyData.Length;
            int barWidth = (availableWidth / barCount) - 10;
            
            // 绘制Y轴
            using (Pen axisPen = new Pen(Color.LightGray, 1))
            {
                g.DrawLine(axisPen, 
                    new Point(bounds.Left + leftPadding, bounds.Top + padding),
                    new Point(bounds.Left + leftPadding, bounds.Bottom - bottomPadding));
            }
            
            // 绘制X轴
            using (Pen axisPen = new Pen(Color.LightGray, 1))
            {
                g.DrawLine(axisPen, 
                    new Point(bounds.Left + leftPadding, bounds.Bottom - bottomPadding),
                    new Point(bounds.Right - padding, bounds.Bottom - bottomPadding));
            }
            
            // 绘制Y轴刻度线
            int yStepCount = 5;
            using (Pen gridPen = new Pen(Color.FromArgb(230, 230, 230), 1))
            using (Font scaleFont = new Font("Arial", 8))
            using (SolidBrush textBrush = new SolidBrush(Color.Gray))
            {
                for (int i = 0; i <= yStepCount; i++)
                {
                    int y = bounds.Bottom - bottomPadding - (i * availableHeight / yStepCount);
                    int value = i * maxValue / yStepCount;
                    
                    // 绘制水平网格线
                    g.DrawLine(gridPen, 
                        new Point(bounds.Left + leftPadding, y),
                        new Point(bounds.Right - padding, y));
                        
                    // 绘制Y轴刻度值
                    string valueText = value.ToString();
                    // 修复CS1503错误，使用整数而不是浮点数
                    int textWidth = (int)g.MeasureString(valueText, scaleFont).Width;
                    g.DrawString(valueText, scaleFont, textBrush, 
                        new Point(bounds.Left + leftPadding - 5 - textWidth, y - 6));
                }
            }
            
            // 绘制柱状图和X轴标签
            using (Font labelFont = new Font("Arial", 8))
            using (SolidBrush textBrush = new SolidBrush(Color.Gray))
            {
                for (int i = 0; i < barCount; i++)
                {
                    int barHeight = (int)((double)monthlyData[i] / maxValue * availableHeight);
                    int barLeft = bounds.Left + leftPadding + i * (barWidth + 10) + 5;
                    int barTop = bounds.Bottom - bottomPadding - barHeight;
                    
                    // 创建柱状图渐变色刷
                    using (System.Drawing.Drawing2D.LinearGradientBrush barBrush = 
                        new System.Drawing.Drawing2D.LinearGradientBrush(
                            new Point(barLeft, barTop),
                            new Point(barLeft, bounds.Bottom - bottomPadding),
                            Color.FromArgb(52, 152, 219),
                            Color.FromArgb(41, 128, 185)))
                    {
                        // 绘制柱状图
                        g.FillRectangle(barBrush, barLeft, barTop, barWidth, barHeight);
                    }
                    
                    // 绘制X轴标签
                    string month = months[i];
                    // 修复CS1503错误，将浮点数转换为整数
                    SizeF labelSizeF = g.MeasureString(month, labelFont);
                    int labelWidth = (int)labelSizeF.Width;
                    g.DrawString(month, labelFont, textBrush, 
                        new Point(barLeft + (barWidth - labelWidth) / 2, bounds.Bottom - bottomPadding + 5));
                }
            }
        }
        
        private void DrawWorkersBarChart(Graphics g, Rectangle bounds)
        {
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            
            // 定义数据
            string[] workers = { "注塑", "电路", "装配总成", "组装", "线头", "冲切", "剪切", "机加工", "上线", "熔接烧结" };
            int[] scores = { 40, 38, 37, 36, 32, 28, 25, 22, 20, 18 };
            Color[] colors = {
                Color.FromArgb(231, 76, 60),   // 红色
                Color.FromArgb(230, 126, 34),  // 橙色
                Color.FromArgb(241, 196, 15),  // 黄色
                Color.FromArgb(46, 204, 113),  // 绿色
                Color.FromArgb(52, 152, 219),  // 蓝色
                Color.FromArgb(155, 89, 182),  // 紫色
                Color.FromArgb(52, 73, 94),    // 深灰色
                Color.FromArgb(22, 160, 133),  // 青色
                Color.FromArgb(41, 128, 185),  // 深蓝色
                Color.FromArgb(142, 68, 173)   // 紫罗兰色
            };
            
            int padding = 40;
            int leftPadding = 100;
            int rightPadding = 40;
            int barHeight = 16;
            int availableWidth = bounds.Width - leftPadding - rightPadding;
            int maxValue = 100; // 使用百分比
            
            int top = bounds.Top + padding;
            int spacing = 10 + barHeight;
            
            // 绘制标题和注释
            using (Font titleFont = new Font("微软雅黑", 10))
            using (SolidBrush textBrush = new SolidBrush(Color.FromArgb(60, 60, 60)))
            {
                g.DrawString("工序", titleFont, textBrush, new Point(bounds.Left + 15, top - 25));
                g.DrawString("不良率", titleFont, textBrush, new Point(bounds.Right - 60, top - 25));
            }
            
            // 绘制条形图
            using (Font labelFont = new Font("微软雅黑", 9))
            using (SolidBrush textBrush = new SolidBrush(Color.FromArgb(80, 80, 80)))
            {
                for (int i = 0; i < workers.Length; i++)
                {
                    // 计算条形宽度
                    int barWidth = (int)((double)scores[i] / maxValue * availableWidth);
                    
                    // 绘制工序名称
                    g.DrawString((i + 1) + ". " + workers[i], labelFont, textBrush, 
                        new Point(bounds.Left + 15, top + i * spacing + 2));
                    
                    // 绘制条形
                    using (System.Drawing.Drawing2D.LinearGradientBrush barBrush = 
                        new System.Drawing.Drawing2D.LinearGradientBrush(
                            new Point(bounds.Left + leftPadding, 0),
                            new Point(bounds.Left + leftPadding + barWidth, 0),
                            colors[i],
                            Color.FromArgb(colors[i].R, colors[i].G, colors[i].B, 150)))
                    {
                        g.FillRectangle(barBrush, 
                            bounds.Left + leftPadding, 
                            top + i * spacing, 
                            barWidth, 
                            barHeight);
                    }
                    
                    // 绘制百分比文本
                    g.DrawString(scores[i] + "%", labelFont, textBrush, 
                        new Point(bounds.Right - 40, top + i * spacing + 2));
                }
            }
        }
        
        private void DrawWIPChart(Graphics g, Rectangle bounds)
        {
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            
            // WIP数据 - 实际和计划
            string[] products = { "HF702", "BC600", "GC030", "SC080", "CD121", "TE065", "ST156", "TE368", "TE029", "TE070" };
            int[] actualValues = { 120, 200, 150, 80, 70, 110, 130, 90, 100, 120 };
            int[] plannedValues = { 140, 230, 300, 260, 150, 120, 160, 120, 110, 130 };
            
            int padding = 35;
            int bottomPadding = 40;
            int availableWidth = bounds.Width - 2 * padding;
            int availableHeight = bounds.Height - 2 * padding - bottomPadding;
            int barCount = products.Length;
            int groupWidth = availableWidth / barCount;
            int barWidth = (groupWidth - 10) / 2;
            
            // 绘制X轴和Y轴
            using (Pen axisPen = new Pen(Color.LightGray, 1))
            {
                // Y轴
                g.DrawLine(axisPen,
                    new Point(bounds.Left + padding, bounds.Top + padding),
                    new Point(bounds.Left + padding, bounds.Bottom - bottomPadding));
                    
                // X轴
                g.DrawLine(axisPen,
                    new Point(bounds.Left + padding, bounds.Bottom - bottomPadding),
                    new Point(bounds.Right - padding, bounds.Bottom - bottomPadding));
            }
            
            // 绘制Y轴刻度
            int maxValue = Math.Max(plannedValues.Max(), actualValues.Max());
            maxValue = ((maxValue / 50) + 1) * 50; // 向上取整到最接近的50
            
            int yStepCount = 5;
            using (Pen gridPen = new Pen(Color.FromArgb(230, 230, 230), 1))
            using (Font scaleFont = new Font("Arial", 8))
            using (SolidBrush textBrush = new SolidBrush(Color.Gray))
            {
                for (int i = 0; i <= yStepCount; i++)
                {
                    int y = bounds.Bottom - bottomPadding - (i * availableHeight / yStepCount);
                    int value = i * maxValue / yStepCount;
                    
                    // 绘制水平网格线
                    g.DrawLine(gridPen,
                        new Point(bounds.Left + padding, y),
                        new Point(bounds.Right - padding, y));
                        
                    // 绘制Y轴刻度值
                    string valueText = value.ToString();
                    // 修复CS1503错误，使用整数而不是浮点数
                    int textWidth = (int)g.MeasureString(valueText, scaleFont).Width;
                    g.DrawString(valueText, scaleFont, textBrush,
                        new Point(bounds.Left + padding - 5 - textWidth, y - 6));
                }
            }
            
            // 绘制图例
            int legendY = bounds.Top + 15;
            int legendX = bounds.Left + bounds.Width / 2 - 80;
            
            using (SolidBrush actualBrush = new SolidBrush(Color.FromArgb(231, 76, 60))) // 红色
            using (SolidBrush plannedBrush = new SolidBrush(Color.FromArgb(52, 152, 219))) // 蓝色
            using (Font legendFont = new Font("Arial", 8))
            using (SolidBrush textBrush = new SolidBrush(Color.Gray))
            {
                // 实际值图例
                g.FillRectangle(actualBrush, legendX, legendY, 15, 10);
                g.DrawString("实际", legendFont, textBrush, new Point(legendX + 20, legendY));
                
                // 计划值图例
                g.FillRectangle(plannedBrush, legendX + 60, legendY, 15, 10);
                g.DrawString("计划", legendFont, textBrush, new Point(legendX + 80, legendY));
            }
            
            // 绘制柱状图和X轴标签
            using (Font labelFont = new Font("Arial", 8))
            using (SolidBrush textBrush = new SolidBrush(Color.Gray))
            using (SolidBrush actualBrush = new SolidBrush(Color.FromArgb(231, 76, 60))) // 红色
            using (SolidBrush plannedBrush = new SolidBrush(Color.FromArgb(52, 152, 219))) // 蓝色
            {
                for (int i = 0; i < barCount; i++)
                {
                    int groupLeft = bounds.Left + padding + i * groupWidth;
                    
                    // 计算柱高
                    int actualHeight = (int)((double)actualValues[i] / maxValue * availableHeight);
                    int plannedHeight = (int)((double)plannedValues[i] / maxValue * availableHeight);
                    
                    // 绘制实际值柱子
                    g.FillRectangle(actualBrush,
                        groupLeft + 5,
                        bounds.Bottom - bottomPadding - actualHeight,
                        barWidth,
                        actualHeight);
                        
                    // 绘制计划值柱子
                    g.FillRectangle(plannedBrush,
                        groupLeft + barWidth + 7,
                        bounds.Bottom - bottomPadding - plannedHeight,
                        barWidth,
                        plannedHeight);
                        
                    // 绘制X轴标签
                    string product = products[i];
                    // 修复CS1503错误，将浮点数转换为整数
                    SizeF labelSizeF = g.MeasureString(product, labelFont);
                    int labelWidth = (int)labelSizeF.Width;
                    int labelLeft = groupLeft + (groupWidth - labelWidth) / 2;
                    g.DrawString(product, labelFont, textBrush,
                        new Point(labelLeft, bounds.Bottom - bottomPadding + 5));
                }
            }
        }
        
        // 创建表格面板的辅助方法
        private TableLayoutPanel CreateTablePanel(string[] headers, string[][] data)
        {
            TableLayoutPanel table = new TableLayoutPanel();
            table.ColumnCount = headers.Length;
            table.RowCount = data.Length + 1; // 加上标题行
            table.BackColor = Color.White;
            table.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
            table.Padding = new Padding(3); // 添加表格内边距
            
            // 添加单元格点击事件
            table.Tag = new Dictionary<string, object>();
            
            // 设置列宽度百分比
            float[] columnWidths = new float[headers.Length];
            for (int i = 0; i < headers.Length; i++)
            {
                columnWidths[i] = 100f / headers.Length;
                table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, columnWidths[i]));
            }
            
            // 设置行高，使表格更宽松
            table.RowStyles.Add(new RowStyle(SizeType.Absolute, 30)); // 标题行高度
            for (int i = 0; i < data.Length; i++)
            {
                table.RowStyles.Add(new RowStyle(SizeType.Absolute, 28)); // 数据行高度
            }
            
            // 添加标题行
            for (int i = 0; i < headers.Length; i++)
            {
                Label headerLabel = new Label();
                headerLabel.Text = headers[i];
                headerLabel.Font = new Font("微软雅黑", 10.5f, FontStyle.Bold); // 增加字体大小
                headerLabel.ForeColor = Color.FromArgb(50, 50, 50); // 加深字体颜色
                headerLabel.TextAlign = ContentAlignment.MiddleCenter;
                headerLabel.Dock = DockStyle.Fill;
                headerLabel.BackColor = Color.FromArgb(245, 245, 245); // 调整背景颜色
                headerLabel.Padding = new Padding(0, 2, 0, 2); // 增加上下内边距
                
                table.Controls.Add(headerLabel, i, 0);
            }
            
            // 添加数据行
            for (int row = 0; row < data.Length; row++)
            {
                for (int col = 0; col < headers.Length && col < data[row].Length; col++)
                {
                    Label cellLabel = new Label();
                    cellLabel.Text = data[row][col];
                    cellLabel.Font = new Font("微软雅黑", 9.5f); // 增加字体大小
                    cellLabel.ForeColor = Color.FromArgb(70, 70, 70); // 调整字体颜色
                    cellLabel.TextAlign = ContentAlignment.MiddleCenter;
                    cellLabel.Dock = DockStyle.Fill;
                    cellLabel.Padding = new Padding(2); // 增加内边距
                    cellLabel.Tag = new int[] { row + 1, col }; // 存储行列索引
                    
                    // 对于特定数据使用不同颜色表示趋势
                    if (col == 2 && data[row][col].Contains("↑"))
                    {
                        cellLabel.ForeColor = Color.Green;
                    }
                    else if (col == 2 && data[row][col].Contains("↓"))
                    {
                        cellLabel.ForeColor = Color.Red;
                    }
                    
                    // 交替行颜色
                    if (row % 2 == 1)
                    {
                        cellLabel.BackColor = Color.FromArgb(248, 248, 252); // 使用更明显但仍然柔和的颜色
                    }
                    else
                    {
                        cellLabel.BackColor = Color.White;
                    }
                    
                    // 对于"查看"、"操作"等交互性单元格，添加特殊样式和事件
                    if (data[row][col] == "查看")
                    {
                        cellLabel.ForeColor = Color.FromArgb(52, 152, 219);
                        cellLabel.Cursor = Cursors.Hand;
                        cellLabel.Font = new Font("微软雅黑", 9, FontStyle.Underline);
                        
                        // 添加鼠标事件
                        cellLabel.MouseEnter += (sender, e) => {
                            Label lbl = sender as Label;
                            lbl.ForeColor = Color.FromArgb(41, 128, 185);
                        };
                        
                        cellLabel.MouseLeave += (sender, e) => {
                            Label lbl = sender as Label;
                            lbl.ForeColor = Color.FromArgb(52, 152, 219);
                        };
                        
                        cellLabel.Click += (sender, e) => {
                            Label lbl = sender as Label;
                            int[] indices = lbl.Tag as int[];
                            
                            // 使用扩展方法触发单元格点击事件
                            table.OnCellClick(new TableLayoutCellClickEventArgs(indices[0], indices[1]));
                        };
                    }
                    
                    table.Controls.Add(cellLabel, col, row + 1);
                }
            }
            
            return table;
        }
        
        // 为TableLayoutPanel添加单元格点击事件
        private void AddCellClickEvent(TableLayoutPanel table, EventHandler<TableLayoutCellClickEventArgs> handler)
        {
            // 使用扩展方法添加事件处理程序
            table.AddCellClickEvent(handler);
            
            // 为表格中的所有Label添加点击事件
            foreach (Control control in table.Controls)
            {
                if (control is Label cellLabel && cellLabel.Tag is int[])
                {
                    cellLabel.Click += (sender, e) => {
                        Label lbl = sender as Label;
                        int[] indices = lbl.Tag as int[];
                        
                        // 使用扩展方法触发单元格点击事件
                        table.OnCellClick(new TableLayoutCellClickEventArgs(indices[0], indices[1]));
                    };
                }
            }
        }
        
        // 获取工单数据
        private string[][] GetWorkOrdersData()
        {
            return new string[][]
            {
                new string[] { "1", "MO202112160001", "已完工", "100%", "274" },
                new string[] { "2", "MO202112160002", "已完工", "80%", "141" },
                new string[] { "3", "MO202112160003", "已完工", "100%", "251" },
                new string[] { "4", "MO202112160004", "已完工", "67%", "491" },
                new string[] { "5", "MO202112160005", "已完工", "55%", "678" }
            };
        }
        
        // 获取客户订单数据
        private string[][] GetCustomerOrdersData()
        {
            return new string[][]
            {
                new string[] { "1", "广东电器电子有限公司", "↑ 97%", "1099" },
                new string[] { "2", "华瑞科技有限公司", "↓ 33%", "7093" },
                new string[] { "3", "华为技术有限公司", "↑ 17%", "5689" },
                new string[] { "4", "小米科技有限责任公司", "↑ 59%", "2375" },
                new string[] { "5", "智联集团", "↓ 90%", "3504" },
                new string[] { "6", "广东移动通信有限公司", "↓ 3%", "2261" }
            };
        }
        
        private void LoadDummyData()
        {
            // 模拟数据已经通过上面的方法添加到控件中
        }
        
        // 窗体大小改变时调整布局
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            
            if (panelTop != null)
            {
                // 调整顶部控件位置
                foreach (Control control in panelTop.Controls)
                {
                    if (control is Label && control.Text == "生产监控仪表板")
                    {
                        control.Location = new Point(this.Width / 2 - 100, 15);
                    }
                    else if (control is Label && control.Text.Contains("年"))
                    {
                        control.Location = new Point(this.Width / 2 - 80, 50);
                    }
                    
                    // 调整卡片容器内的卡片宽度
                    if (control is Panel cardsContainer && cardOutputCount != null)
                    {
                        int cardWidth = (this.Width - 80) / 4; // 减小卡片宽度，增加间隔
                        
                        cardOutputCount.Width = cardWidth;
                        cardOutputCount.Left = 20; // 增加左边距
                        
                        cardProductionCount.Width = cardWidth;
                        cardProductionCount.Left = cardOutputCount.Right + 15; // 增加卡片间距
                        
                        cardInventoryCount.Width = cardWidth;
                        cardInventoryCount.Left = cardProductionCount.Right + 15; // 增加卡片间距
                        
                        cardDefectCount.Width = cardWidth;
                        cardDefectCount.Left = cardInventoryCount.Right + 15; // 增加卡片间距
                    }
                }
            }
            
            // 调整各页面内的控件大小和位置
            if (pageOverview != null && pageOverview.Controls.Count > 0)
            {
                foreach (Control container in pageOverview.Controls)
                {
                    foreach (Control panel in container.Controls)
                    {
                        if (panel is Panel upperPanel && panel.Dock == DockStyle.Top)
                        {
                            foreach (Control chartPanel in upperPanel.Controls)
                            {
                                if (chartPanel.Dock == DockStyle.Left || chartPanel.Dock == DockStyle.Right)
                                {
                                    chartPanel.Width = this.Width / 2 - 30;
                                }
                            }
                        }
                        else if (panel is Panel lowerPanel && panel.Dock == DockStyle.Fill)
                        {
                            int panelWidth = this.Width / 3 - 20;
                            
                            foreach (Control p in lowerPanel.Controls)
                            {
                                if (p == panelWorkOrders)
                                {
                                    p.Width = panelWidth;
                                    
                                    // 调整表格大小
                                    if (p.Controls.Count > 1 && p.Controls[1] is TableLayoutPanel tableWorkOrders)
                                    {
                                        tableWorkOrders.Size = new Size(panelWidth - 20, 200);
                                    }
                                }
                                else if (p == panelCustomerOrders)
                                {
                                    p.Width = panelWidth;
                                    p.Left = panelWorkOrders.Right + 10;
                                    
                                    // 调整表格大小
                                    if (p.Controls.Count > 1 && p.Controls[1] is TableLayoutPanel tableCustomerOrders)
                                    {
                                        tableCustomerOrders.Size = new Size(panelWidth - 20, 200);
                                    }
                                }
                                else if (p == panelWIP)
                                {
                                    p.Width = panelWidth;
                                    p.Left = panelCustomerOrders.Right + 10;
                                }
                            }
                        }
                    }
                }
            }
            
            // 调整其他页面中的表格大小
            if (pageProduction != null && pageProduction.Controls.Count > 0)
            {
                foreach (Control container in pageProduction.Controls)
                {
                    foreach (Control control in container.Controls)
                    {
                        if (control is TableLayoutPanel table)
                        {
                            table.Size = new Size(this.Width - 60, 400);
                        }
                        else if (control is Button btn && btn.Text == "新增订单")
                        {
                            btn.Location = new Point(this.Width - 150, 48);
                        }
                    }
                }
            }
            
            if (pageOrders != null && pageOrders.Controls.Count > 0)
            {
                foreach (Control container in pageOrders.Controls)
                {
                    foreach (Control control in container.Controls)
                    {
                        if (control is TableLayoutPanel table)
                        {
                            table.Size = new Size(this.Width - 60, 400);
                        }
                        else if (control is Button btn && btn.Text == "新增订单")
                        {
                            btn.Location = new Point(this.Width - 150, 48);
                        }
                    }
                }
            }
            
            if (pageAnalytics != null && pageAnalytics.Controls.Count > 0)
            {
                foreach (Control container in pageAnalytics.Controls)
                {
                    foreach (Control control in container.Controls)
                    {
                        if (control is Panel analysisPanel && control.Location.Y > 80)
                        {
                            control.Size = new Size(this.Width - 60, 400);
                        }
                        else if (control is Button btn && btn.Text == "生成报表")
                        {
                            btn.Location = new Point(this.Width - 150, 48);
                        }
                    }
                }
            }
            
            // 强制重绘所有自定义图表
            this.Invalidate(true);
        }

        private void CreateBottomPanels()
        {
            // 创建工单表格面板
            panelWorkOrders = CreatePanel("工单完成情况", DockStyle.None, this.Width / 3 - 20);
            panelWorkOrders.Height = 250;
            panelWorkOrders.Location = new Point(10, 10);
            
            // 添加工单数据表格
            TableLayoutPanel tableWorkOrders = CreateTablePanel(
                new string[] { "序号", "工单号", "状态", "进度", "总数量" },
                GetWorkOrdersData()
            );
            tableWorkOrders.Location = new Point(10, 40);
            tableWorkOrders.Size = new Size(panelWorkOrders.Width - 20, 200);
            AddCellClickEvent(tableWorkOrders, TableWorkOrders_CellClick);
            panelWorkOrders.Controls.Add(tableWorkOrders);
            
            // 创建客户订单表格面板
            panelCustomerOrders = CreatePanel("出货订单数据", DockStyle.None, this.Width / 3 - 20);
            panelCustomerOrders.Height = 250;
            panelCustomerOrders.Location = new Point(panelWorkOrders.Right + 10, 10);
            
            // 添加客户订单数据表格
            TableLayoutPanel tableCustomerOrders = CreateTablePanel(
                new string[] { "序号", "客户", "同比", "订单量" },
                GetCustomerOrdersData()
            );
            tableCustomerOrders.Location = new Point(10, 40);
            tableCustomerOrders.Size = new Size(panelCustomerOrders.Width - 20, 200);
            AddCellClickEvent(tableCustomerOrders, TableCustomerOrders_CellClick);
            panelCustomerOrders.Controls.Add(tableCustomerOrders);
            
            // 创建WIP图表面板
            panelWIP = CreatePanel("生产WIP", DockStyle.None, this.Width / 3 - 20);
            panelWIP.Height = 250;
            panelWIP.Location = new Point(panelCustomerOrders.Right + 10, 10);
            
            // 添加WIP图表绘制区域
            Panel chartWIP = new Panel();
            chartWIP.Dock = DockStyle.Fill;
            chartWIP.Padding = new Padding(10, 40, 10, 10);
            
            // 添加WIP图表绘制
            chartWIP.Paint += (sender, e) => 
            {
                DrawWIPChart(e.Graphics, chartWIP.ClientRectangle);
            };
            
            // 添加WIP信息标签
            Panel wipInfoPanel = new Panel();
            wipInfoPanel.Dock = DockStyle.Right;
            wipInfoPanel.Width = 120;
            wipInfoPanel.BackColor = Color.Transparent;
            
            // 当日WIP数量
            Label lblWIPTitle = new Label();
            lblWIPTitle.Text = "当日WIP总数";
            lblWIPTitle.Font = new Font("微软雅黑", 9);
            lblWIPTitle.ForeColor = Color.Gray;
            lblWIPTitle.AutoSize = true;
            lblWIPTitle.Location = new Point(5, 50);
            
            Label lblWIPValue = new Label();
            lblWIPValue.Text = "341";
            lblWIPValue.Font = new Font("微软雅黑", 16, FontStyle.Bold);
            lblWIPValue.ForeColor = Color.FromArgb(52, 152, 219);
            lblWIPValue.AutoSize = true;
            lblWIPValue.Location = new Point(5, 70);
            
            Label lblWIPCompare = new Label();
            lblWIPCompare.Text = "同比上月增长 31%";
            lblWIPCompare.Font = new Font("微软雅黑", 8);
            lblWIPCompare.ForeColor = Color.FromArgb(46, 204, 113);
            lblWIPCompare.AutoSize = true;
            lblWIPCompare.Location = new Point(5, 95);
            
            // 完成总数
            Label lblCompletedTitle = new Label();
            lblCompletedTitle.Text = "完成总数";
            lblCompletedTitle.Font = new Font("微软雅黑", 9);
            lblCompletedTitle.ForeColor = Color.Gray;
            lblCompletedTitle.AutoSize = true;
            lblCompletedTitle.Location = new Point(5, 130);
            
            Label lblCompletedValue = new Label();
            lblCompletedValue.Text = "5942";
            lblCompletedValue.Font = new Font("微软雅黑", 16, FontStyle.Bold);
            lblCompletedValue.ForeColor = Color.FromArgb(52, 152, 219);
            lblCompletedValue.AutoSize = true;
            lblCompletedValue.Location = new Point(5, 150);
            
            Label lblCompletedCompare = new Label();
            lblCompletedCompare.Text = "同比上月增长 63%";
            lblCompletedCompare.Font = new Font("微软雅黑", 8);
            lblCompletedCompare.ForeColor = Color.FromArgb(46, 204, 113);
            lblCompletedCompare.AutoSize = true;
            lblCompletedCompare.Location = new Point(5, 175);
            
            // 添加到信息面板
            wipInfoPanel.Controls.Add(lblWIPTitle);
            wipInfoPanel.Controls.Add(lblWIPValue);
            wipInfoPanel.Controls.Add(lblWIPCompare);
            wipInfoPanel.Controls.Add(lblCompletedTitle);
            wipInfoPanel.Controls.Add(lblCompletedValue);
            wipInfoPanel.Controls.Add(lblCompletedCompare);
            
            // 添加到WIP面板
            panelWIP.Controls.Add(wipInfoPanel);
            panelWIP.Controls.Add(chartWIP);
            
            // 这里不需要添加到底部面板，因为已经在CreateOverviewPage方法中处理了
        }
    }
}